﻿package view
{
    import com.core.*;
    import com.sh.game.util.*;
    import control.*;
    import flash.display.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.text.*;
    import flash.utils.*;
    import morn.core.components.*;
    import pluginfw.*;

    public class BigFontINotice extends Sprite
    {
        private var label:Label;
        private var artCon:Container;
        public var mFilter:GlowFilter;
        private var _intvalid:uint;
        private var _autoArr:Array;
        private var _timeID:uint;

        public function BigFontINotice()
        {
            this.mFilter = new GlowFilter(MColor.New55, 0.8, 10, 10, 4, BitmapFilterQuality.MEDIUM);
            this.label = new Label("");
            this.label.color = MColor.New1;
            this.label.bold = true;
            this.addChild(this.label);
            this.label.filters = [this.mFilter];
            this.label.align = "center";
            this.label.width = 1200;
            this.label.height = 40;
            this.label.size = 20;
            this.artCon = new Container();
            this.artCon.mouseEnabled = false;
            this.artCon.mouseChildren = false;
            this.artCon.width = this.label.width;
            this.artCon.height = this.label.height;
            this.mouseEnabled = false;
            this.mouseChildren = false;
            ModelProxy.addObserver("dazibao", Control.create(DaZiBaoControl, this));
            this.initAutoShow();
            return;
        }// end function

        private function initAutoShow() : void
        {
            var _loc_2:Object = null;
            var _loc_1:* = ConfigDictionary.data.dazibao;
            if (_loc_1[1])
            {
                this._autoArr = new Array();
                for each (_loc_2 in _loc_1[1])
                {
                    
                    this._autoArr.push(_loc_2);
                }
                this._intvalid = setInterval(this.randomNotice, 50000);
            }
            return;
        }// end function

        private function randomNotice() : void
        {
            if (!this.visible && this._autoArr && this._autoArr.length > 0)
            {
                this.showContent(this._autoArr[int(this._autoArr.length * Math.random())].content);
            }
            return;
        }// end function

        public function showContent(param1:String) : void
        {
            if (this.artCon.parent)
            {
                this.artCon.parent.removeChild(this.artCon);
            }
            this.label.text = param1;
            this.label.visible = true;
            this.visible = true;
            if (this._timeID > 0)
            {
                clearTimeout(this._timeID);
                this._timeID = 0;
            }
            this._timeID = setTimeout(this.close, 8000);
            return;
        }// end function

        public function show(param1:Object) : void
        {
            if (this.artCon.parent)
            {
                this.artCon.parent.removeChild(this.artCon);
            }
            this.label.visible = false;
            var _loc_2:* = param1 as Array;
            if (_loc_2 == null || _loc_2.length == 0)
            {
                return;
            }
            var _loc_3:* = _loc_2.pop();
            var _loc_4:* = ConfigDictionary.data.announce[_loc_3];
            if (_loc_3 == 298)
            {
                ModelProxy.change("mainui", "showNbFly", {type:2, id:3});
            }
            if (_loc_4 == null)
            {
                return;
            }
            var _loc_5:* = _loc_4.text;
            if (!_loc_4.text || _loc_5 == "")
            {
                return;
            }
            var _loc_6:* = StringUtil.substitute(_loc_5, _loc_2);
            switch(_loc_3)
            {
                case 91:
                case 93:
                {
                    this.createArt(_loc_6);
                    break;
                }
                default:
                {
                    this.label.text = _loc_6;
                    this.label.visible = true;
                    break;
                    break;
                }
            }
            this.visible = true;
            if (this._timeID > 0)
            {
                clearTimeout(this._timeID);
                this._timeID = 0;
            }
            this._timeID = setTimeout(this.close, 8000);
            return;
        }// end function

        public function close() : void
        {
            this.visible = false;
            return;
        }// end function

        private function createArt(param1:String) : void
        {
            var _loc_2:* = new Sprite();
            var _loc_3:* = GradientType.LINEAR;
            var _loc_4:Array = [16729344, 16776960, 16777015];
            var _loc_5:Array = [1, 1, 1];
            var _loc_6:Array = [0, 200, 255];
            var _loc_7:* = new Matrix();
            new Matrix().createGradientBox(1200, 24, Math.PI / 2);
            var _loc_8:* = SpreadMethod.PAD;
            _loc_2.graphics.beginGradientFill(_loc_3, _loc_4, _loc_5, _loc_6, _loc_7, _loc_8);
            _loc_2.graphics.drawRect(0, 0, 1200, 24);
            _loc_2.graphics.endFill();
            this.artCon.addChild(_loc_2);
            addChild(this.artCon);
            var _loc_9:* = new TextField();
            new TextField().width = 1200;
            _loc_9.defaultTextFormat = new TextFormat("宋体", this.label.size, null, true, null, null, null, null, TextFormatAlign.CENTER);
            _loc_9.text = param1;
            _loc_9.selectable = false;
            var _loc_10:* = new MovieClip();
            this.artCon.addChild(_loc_10);
            _loc_10.addChild(_loc_9);
            this.artCon.mask = _loc_10;
            this.artCon.filters = null;
            this.artCon.filters = [new GlowFilter(16753920, 1, 4, 4)];
            this.artCon.cacheAsBitmap = true;
            return;
        }// end function

    }
}
